<template>
  <div id="app">
    <div class="admin-layout">
      <!-- 侧边栏 -->
      <aside class="sidebar">
        <div class="logo">
          <h2>管理后台</h2>
        </div>
        <nav class="nav">
          <router-link to="/" class="nav-item">
            <span>仪表盘</span>
          </router-link>
          <router-link to="/users" class="nav-item">
            <span>用户管理</span>
          </router-link>
          <router-link to="/products" class="nav-item">
            <span>商品管理</span>
          </router-link>
          <router-link to="/orders" class="nav-item">
            <span>订单管理</span>
          </router-link>
          <router-link to="/categories" class="nav-item">
            <span>分类管理</span>
          </router-link>
          <router-link to="/inventory" class="nav-item">
            <span>库存管理</span>
          </router-link>
          <router-link to="/settings" class="nav-item">
            <span>系统设置</span>
          </router-link>
        </nav>
      </aside>
      
      <!-- 主内容区域 -->
      <main class="main-content">
        <header class="header">
          <h1>{{ currentPageTitle }}</h1>
        </header>
        <div class="content">
          <router-view />
        </div>
      </main>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  computed: {
    currentPageTitle() {
      const route = this.$route
      const titles = {
        '/': '仪表盘',
        '/users': '用户管理',
        '/products': '商品管理',
        '/orders': '订单管理',
        '/categories': '分类管理',
        '/inventory': '库存管理',
        '/settings': '系统设置'
      }
      return titles[route.path] || '管理后台'
    }
  }
}
</script>

<style scoped>
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: #2c3e50;
  color: white;
  padding: 20px 0;
}

.logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid #34495e;
}

.logo h2 {
  margin: 0;
  font-size: 18px;
}

.nav {
  padding: 20px 0;
}

.nav-item {
  display: block;
  padding: 12px 20px;
  color: #ecf0f1;
  text-decoration: none;
  transition: background 0.3s;
}

.nav-item:hover,
.nav-item.router-link-active {
  background: #34495e;
  color: #3498db;
}

.main-content {
  flex: 1;
  background: #f5f6fa;
}

.header {
  background: white;
  padding: 20px 30px;
  border-bottom: 1px solid #e1e8ed;
}

.header h1 {
  margin: 0;
  font-size: 24px;
  color: #2c3e50;
}

.content {
  padding: 30px;
}
</style> 